﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Wpf_ClientLeger.BusinessObject;

namespace Wpf_ClientLeger.IHM
{
    /// <summary>
    /// Logique d'interaction pour Preparation_Menu.xaml
    /// </summary>
    public partial class Preparation_Menu : Window
    {
        Parametres paramAppli;
        User currentUser;

        public Preparation_Menu(Parametres param, User user)
        {
            InitializeComponent();
            paramAppli = param;
            currentUser = user;
            lbl_nom.Content = user.preUser + " " + user.nomUser;

            //Gestion des droits
            foreach (int userParam in user.confUser)
            {
                if (userParam == param.id_confAdminBP)
                {
                    bt_saisieBP.IsEnabled = true;
                    bt_validationBP.IsEnabled = true;
                }
                else if (userParam == param.id_confPrepa)
                {
                    bt_saisieBP.IsEnabled = true;
                }
            }
        }

        private void bt_retour_Click(object sender, RoutedEventArgs e)
        {
            MenuPrincipal menuP = new MenuPrincipal(paramAppli, currentUser);
            menuP.Show();
            this.Close();
        }

        //saisie d'une ligne de BP
        private void bt_saisieBP_Click(object sender, RoutedEventArgs e)
        {
            SaisieBP menuSaisie = new SaisieBP(this.paramAppli, this.currentUser);
            menuSaisie.Show();
            this.Close();
        }

        //test de la touche escape (abandon)
        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                bt_retour_Click(sender, e);
            }
        }

        //validation des BP
        private void bt_validationBP_Click(object sender, RoutedEventArgs e)
        {
            ValidationBP menuValidationBp = new ValidationBP(this.paramAppli, this.currentUser);
            menuValidationBp.Show();
            this.Close();
        }
    }
}
